//
//  UIBarButtonItem+Extensions.swift
//  传智微博
//
//  Created by zhoujiming on 2016/12/24.
//  Copyright © 2016年 gmcc. All rights reserved.
//

import UIKit

extension UIBarButtonItem{
    
    convenience init(title : String, fontSize : CGFloat = 16, target : AnyObject?, action : Selector, isBack : Bool = false) {
        let btn : UIButton = UIButton.cz_textButton(title, fontSize: fontSize, normalColor:  UIColor.darkGray, highlightedColor: UIColor.orange)
        
        if isBack {
            btn.setImage(UIImage(named: "navigationbar_back_withtext"), for: UIControlState(rawValue: 0))
            btn.setImage(UIImage(named: "navigationbar_back_withtext_highlighted"), for: .highlighted)
            
            btn.sizeToFit()
        }
        
        btn.addTarget(target, action: action, for: .touchUpInside)
        
        self.init(customView : btn)
    }
}
